/*
 * @Author: thats-all-right-ha-ha 8280209+thats-all-right-ha-ha@user.noreply.gitee.com
 * @Date: 2024-06-06 17:49:28
 * @LastEditors: thats-all-right-ha-ha 8280209+thats-all-right-ha-ha@user.noreply.gitee.com
 * @LastEditTime: 2024-06-07 22:36:03
 * @FilePath: \vue-admin-template\src\api\news.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from '@/utils/request'

// 获取文章列表
export const getNewList = (params) => {
  return request({
    url: '/newslist',
    method: 'get',
    params
  })
}

// 提交文章封面
export const uploadImgCover = (data) => {
  console.log(data)
  return request({
    url: '/upload/news',
    method: 'post',
    'Content-Type': 'multipart/form-data',
    data
  })
}
// 提交文章内容
export const uploadArticle = (data) => {
  return request({
    url: '/news',
    method: 'post',
    data
  })
}

// 获取文章详情
export const getNewDetail = (id) => {
  return request({
    url: `/news/${id}`,
    method: 'get'
  })
}
// 更新文章
export const updateNew = (id, data) => {
  return request({
    url: `/news/${id}`,
    method: 'put',
    data
  })
}

// 删除文章
export const delNew = (id) => {
  return request({
    url: `/news/${id}`,
    method: 'delete'
  })
}
